package com.only.common.util;

import java.util.regex.Pattern;

/**
 * @author only
 * @date 2024/4/25
 * @description
 */
public class IPAddressValidator {
    private static final String IPADDRESS_PATTERN = "^((25[0-5]|2[0-4]\\d|[01]?\\d\\d?)\\.){3}(25[0-5]|2[0-4]\\d|[01]?\\d\\d?)$";
    private static final Pattern pattern = Pattern.compile(IPADDRESS_PATTERN);

    public static boolean isValid(String ip) {
        if (ip == null) {
            return false;
        }
        return pattern.matcher(ip).matches();
    }
}
